package com.lc.afbx.adapters;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import com.lc.afbx.BaseApplication;
import com.lc.afbx.R;
import com.lc.afbx.conn.PostApiCasualty;

import java.util.List;

/**
 * Created by Administrator on 2016/7/11.
 */
public class DathAdater extends BaseAdapter {
    private Context context;
    private List<PostApiCasualty.DathInfo> dathInfoList;

    public DathAdater(Context context, List<PostApiCasualty.DathInfo> dathInfoList) {
        this.context = context;
        this.dathInfoList = dathInfoList;
    }


    @Override
    public int getCount() {
        return dathInfoList.size();
    }

    @Override
    public Object getItem(int position) {
        return dathInfoList.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {

        ViewHolder holder = null;

        if (convertView == null) {

            convertView = LayoutInflater.from(context).inflate(R.layout.dath_info_item, null);
            BaseApplication.ScaleScreenHelper.loadView((ViewGroup) convertView);
            holder = new ViewHolder();

            holder.percent = (TextView) convertView.findViewById(R.id.beneficiary);
            holder.name = (TextView) convertView.findViewById(R.id.name_liftitem);

            convertView.setTag(holder);
        } else {

            holder = (ViewHolder) convertView.getTag();
        }

        holder.percent.setText(dathInfoList.get(position).benefit_ratio.replace("%", "") + "%");
        holder.name.setText(dathInfoList.get(position).name);

        return convertView;
    }

    class ViewHolder {
        TextView name, percent;
    }


}
